package net.onmotion.network;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Image;

public class HttpData extends NetworkData {

    public HttpData(){
        baos = new ByteArrayOutputStream();
        dos = new DataOutputStream(baos);
        first = true;
        contentType = "application/x-www-form-urlencoded"; 
        method = HttpConnection.POST;
    }
    
    public void addPart(String key, String data){
        try {            
            if (first){
                first = false;
                //dos.writeUTF("?");
            } else {
                dos.write("&".getBytes());                
            }            
            dos.write(key.getBytes());
            dos.write("=".getBytes());
            dos.write(data.getBytes());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }        
    }
}
